﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using OnlineStore.Dal;

namespace OnlineStore.Bll
{
    public class bizCart:tbProduct
    {
        int _NumOrd;
        List<bizCart> list;
        public bizCart(tbProduct a)
        {
            this.ID = a.ID;
            this.Product_ID = a.Product_ID;
            this.Product_Name = a.Product_Name;
            this.Price = a.Price;
            this.Size = a.Size;
            this.Color = a.Color;
            this.Type = a.Type;
            this.Pur_Qty = a.Pur_Qty;
            this.Ord_Qty = a.Ord_Qty;
            this.Stock_Qty = a.Stock_Qty;
            this.Clock = a.Clock;
            this.Picture = a.Picture;
            this.Ord_Qty = a.Ord_Qty;

        }

        public bizCart()
        {
            // TODO: Complete member initialization
        }
        public List<bizCart> addToCart(List<bizCart> list, string ID, string NumberOrder)
        {
            if (ID == null) return list;
            int id = int.Parse(ID);
            if (list != null)
            {
                foreach (bizCart i in list)
                    if (i == id)
                    {
                        i._NumOrd += int.Parse(NumberOrder);
                        return list;
                    }
            }
            else
                list = new List<bizCart>();
            DalProduct _dalProduct = new DalProduct();
            bizCart _product = new bizCart(_dalProduct.Search(id));
            if ((object)_product ==null) return list;
            _product._NumOrd = int.Parse(NumberOrder);
            list.Add(_product);
            return list;
        }
        public static bool operator ==(bizCart a, int ID)
        {
            return a.ID == ID;
        }
        public static bool operator !=(bizCart a, int ID)
        {
            return a.ID != ID;
        }
        public static bool operator ==(bizCart a, bizCart b)
        {
            return a.ID == b.ID;
        }
        public static bool operator !=(bizCart a, bizCart b)
        {
            return a.ID != b.ID;
        }
    }
}